/*
 * create:2016年1月11日 下午5:39:29
 * author:wangds  
 */

package net.wangds.common.context.test;

import java.util.logging.Logger;

import junit.framework.TestCase;
import net.wangds.common.context.BeanContext;
import net.wangds.common.context.BeanContextFactory;

import org.junit.Test;

/**
 * .
 * 
 * @author wangds
 *
 */
public class ContextTestCase {

  /**
   * .
   * 
   * @author wangds 2016年1月11日 下午6:01:34.
   */
  @Test
  public void test() {

    BeanContext c = BeanContextFactory.getBeanContext("test");
    TestCase.assertNotNull(c);
    c = BeanContextFactory.getBeanContext(null);
    TestCase.assertNull(c);
    c = new BeanContextFactory().getInstance("test", null, "test");
    TestCase.assertNotNull(c);
    c = new BeanContextFactory().getInstance("test", "aaa");
    TestCase.assertNotNull(c);

    c = new BeanContextFactory().getInstance("test", "test1");
    TestCase.assertNotNull(c);
    try {
      c = new BeanContextFactory(){
        protected void testNeedAnException() {
          throw new RuntimeException();
        };
      }.getInstance("test2");
    } catch (Exception e) {
      Logger.getGlobal().info(e.getLocalizedMessage());
    }
    try {
      c = new BeanContextFactory().getInstance("test3","test");
    } catch (Exception e) {
      Logger.getGlobal().info(e.getLocalizedMessage());
    }
    
  }

}
